<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.4.1">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.4.1">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.4.1">
  <link rel="mask-icon" href="/images/logo.svg?v=7.4.1" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.4.1">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '7.4.1',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":"mac"},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: true,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="Python、Oracle，金融科技">
<meta property="og:type" content="website">
<meta property="og:title" content="ShellyAn">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="ShellyAn">
<meta property="og:description" content="Python、Oracle，金融科技">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ShellyAn">
<meta name="twitter:description" content="Python、Oracle，金融科技">
  <link rel="canonical" href="http://yoursite.com/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: true,
    isPost: false,
    isPage: false,
    isArchive: false
  };
</script>

  <title>ShellyAn</title>
  








  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">ShellyAn</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">实践出真知</p>
      
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
        
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
      
    
      
      
        
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      
    
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div class="content">
            

  <div class="posts-expand">
        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/10/28/如何事半功倍的学习算法与数据结构/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Shelly An">
      <meta itemprop="description" content="Python、Oracle，金融科技">
      <meta itemprop="image" content="/images/shelly.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ShellyAn">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            
            <a href="/2019/10/28/如何事半功倍的学习算法与数据结构/" class="post-title-link" itemprop="url">未命名</a>
          
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-10-28 14:06:13 / 修改时间：14:15:12" itemprop="dateCreated datePublished" datetime="2019-10-28T14:06:13+08:00">2019-10-28</time>
            </span>
          
            

            
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="如何事半功倍的学习算法与数据结构"><a href="#如何事半功倍的学习算法与数据结构" class="headerlink" title="如何事半功倍的学习算法与数据结构"></a>如何事半功倍的学习算法与数据结构</h1><h2 id="精通一个领域"><a href="#精通一个领域" class="headerlink" title="精通一个领域"></a>精通一个领域</h2><h3 id="chunk-it-up-切碎知识点"><a href="#chunk-it-up-切碎知识点" class="headerlink" title="chunk it up 切碎知识点"></a>chunk it up 切碎知识点</h3><p>一般书或者课程都会把知识点切碎的很好，但是要注意知识点之间的联系。</p>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1572242009472.png" alt="1572242009472"></p>
<p>把这个领域想象成一个游戏，分解出几个大块，最后再串起来，形成知识树</p>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1572242122640.png" alt="1572242122640"></p>
<p>还要注意知识点之间的对比</p>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\1572242177995.png" alt="1572242177995"></p>
<h3 id="deliberate-practicing-刻意练习"><a href="#deliberate-practicing-刻意练习" class="headerlink" title="deliberate practicing 刻意练习"></a>deliberate practicing 刻意练习</h3><ul>
<li>练习缺陷、弱点地方</li>
<li>不舒服、不爽、枯燥</li>
<li>切题四件套</li>
</ul>
<h3 id="feedback-反馈"><a href="#feedback-反馈" class="headerlink" title="feedback 反馈"></a>feedback 反馈</h3><ul>
<li>主动反馈：主动去找<ul>
<li>github：别人的项目</li>
<li>leetcode<ul>
<li>做题：切题四件套</li>
<li>别人的写法</li>
</ul>
</li>
<li>第一视角直播（视频）</li>
</ul>
</li>
<li>被动反馈<ul>
<li>大佬帮你code review</li>
<li>教练看你打，给你反馈</li>
</ul>
</li>
</ul>
<h3 id="切题四件套"><a href="#切题四件套" class="headerlink" title="切题四件套"></a>切题四件套</h3><ul>
<li>clarification：明确题目意思</li>
<li>possible solutions：所有可能的解，用最佳解<ul>
<li>compare(time/space)</li>
<li>optimal(加强)</li>
</ul>
</li>
<li>coding(多写)</li>
<li>test cases：测试案例</li>
</ul>
<h2 id="如何计算算法复杂度"><a href="#如何计算算法复杂度" class="headerlink" title="如何计算算法复杂度"></a>如何计算算法复杂度</h2>
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

    
        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/10/12/2019-10-18/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Shelly An">
      <meta itemprop="description" content="Python、Oracle，金融科技">
      <meta itemprop="image" content="/images/shelly.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ShellyAn">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            
            <a href="/2019/10/12/2019-10-18/" class="post-title-link" itemprop="url">第一周ARTS 2019-10-21 至 2019-10-25</a>
          
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-10-12 18:37:59" itemprop="dateCreated datePublished" datetime="2019-10-12T18:37:59+08:00">2019-10-12</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-28 13:45:41" itemprop="dateModified" datetime="2019-10-28T13:45:41+08:00">2019-10-28</time>
              </span>
            
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Algorithm"><a href="#Algorithm" class="headerlink" title="Algorithm"></a>Algorithm</h3><p>一个leetcode算法题</p>
<h5 id="链表的特点："><a href="#链表的特点：" class="headerlink" title="链表的特点："></a>链表的特点：</h5><ul>
<li><p>不需要连续的内存空间</p>
</li>
<li><p>链表中每个节点的结构：</p>
<ul>
<li>data：数据</li>
<li>next：后继指针，下一个节点的地址</li>
<li>prev：双向链表特有</li>
</ul>
</li>
<li><p>头结点：第一个结点，记录链表的基地址</p>
</li>
<li><p>尾结点：最后一个结点</p>
</li>
<li><p>支持查找O(n)、插入O(1)、删除O(1)操作</p>
<p><img src="https://static001.geekbang.org/resource/image/45/17/452e943788bdeea462d364389bd08a17.jpg" alt="img"> </p>
</li>
</ul>
<h5 id="常见类型"><a href="#常见类型" class="headerlink" title="常见类型"></a>常见类型</h5><ol>
<li><p>单链表</p>
<ul>
<li>节省内存</li>
</ul>
</li>
<li><p>循环链表</p>
<ul>
<li>链尾到链头实现更容易</li>
</ul>
</li>
<li>双向链表（空间换时间）<ul>
<li>插入和删除给定指针指向的节点更效率O(1)</li>
<li>按值查询的效率更高一些，是单链的一半</li>
</ul>
</li>
<li><p>双向循环链表</p>
</li>
<li><p><strong>删除链表中的节点</strong>（<strong>leetcode237</strong>）</p>
<p>从链表中删除一个数据有两种情况：</p>
<ul>
<li>删除节点中“值等于某个给定值”的节点（本题）<ul>
<li>无论单链还是双链，查找的时间复杂度都为O(n)</li>
<li>双链效率更高一点</li>
</ul>
</li>
<li>删除给定指针指向的节点<ul>
<li>双链表是O(1)，单链表是O(n)</li>
</ul>
</li>
</ul>
</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Definition for singly-linked list.</span></span><br><span class="line"><span class="comment"># class ListNode:</span></span><br><span class="line"><span class="comment">#     def __init__(self, x):</span></span><br><span class="line"><span class="comment">#         self.val = x</span></span><br><span class="line"><span class="comment">#         self.next = None</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">deleteNode</span><span class="params">(self, node)</span>:</span></span><br><span class="line">        <span class="string">"""</span></span><br><span class="line"><span class="string">        :type node: ListNode</span></span><br><span class="line"><span class="string">        :rtype: void Do not return anything, modify node in-place instead.</span></span><br><span class="line"><span class="string">        """</span></span><br><span class="line">        node.val, node.next = node.next.val, node.next.next</span><br></pre></td></tr></table></figure>
<h5 id="写链表代码的技巧："><a href="#写链表代码的技巧：" class="headerlink" title="写链表代码的技巧："></a>写链表代码的技巧：</h5><ol>
<li><p>理解指针或引用的含义</p>
<ol>
<li>p-&gt;next=q   p 结点中的 next 指针存储了 q 结点的内存地址。 </li>
<li>p-&gt;next=p-&gt;next-&gt;next   p 结点的 next 指针存储了 p 结点的下下一个结点的内存地址。 </li>
</ol>
</li>
<li><p>警惕指针丢失和内存泄漏</p>
<ul>
<li>插入节点时注意操作顺序</li>
<li>删除节点时记得手动释放内存空间（java不需要）</li>
</ul>
</li>
</ol>
<p>错误示例：</p>
   <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">p-&gt;next = x; <span class="comment">// 将p的next指针指向x结点；</span></span><br><span class="line">x-&gt;next = p-&gt;next; <span class="comment">// 将x的结点的next指针指向p结点；</span></span><br></pre></td></tr></table></figure>
<p>正确示例：</p>
   <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">x-&gt;next = p-&gt;next; <span class="comment">// 将x的结点的next指针指向p结点；</span></span><br><span class="line">p-&gt;next = x; <span class="comment">// 将p的next指针指向x结点；</span></span><br></pre></td></tr></table></figure>
<h3 id="Review"><a href="#Review" class="headerlink" title="Review"></a>Review</h3><p>阅读并点评一篇英文技术文章</p>
<p><strong><a href="https://huyenchip.com/2019/08/21/glassdoor-interview-reviews-tech-hiring-cultures.html" target="_blank" rel="noopener">What Glassdoor interview reviews reveal about tech hiring cultures</a></strong></p>
<h3 id="Tip"><a href="#Tip" class="headerlink" title="Tip"></a>Tip</h3><p>学习一个技术技巧</p>
<h4 id="Oralce的开窗函数rank"><a href="#Oralce的开窗函数rank" class="headerlink" title="Oralce的开窗函数rank()"></a>Oralce的开窗函数rank()</h4><p>部门工资前三高的所有员工</p>
<p>rank()和dense_rank()的区别，就是并列排名算1位还是2位。rank是算1位，dense_rank算2位</p>
<p>其他用法是一样的，代码示例如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">select Department,Employee,Salary from</span><br><span class="line">(select t2.Name as Department ,t1.Name as Employee ,t1.Salary , DENSE_RANK() over(partition by t2.Name  order by t1.Salary desc) as rn</span><br><span class="line">from Employee t1, Department t2</span><br><span class="line">where t1.DepartmentId = t2.Id) t</span><br><span class="line">where t.rn &lt;= 3</span><br></pre></td></tr></table></figure>
<ul>
<li>partition by 按什么分区，可以理解为不同区的分开作比较</li>
<li>order by 按哪个字段排序</li>
</ul>
<p>用开窗函数可以非常效率的用较短的语句实现较复杂的功能，且对异常情况处理更包容。</p>
<h3 id="Share"><a href="#Share" class="headerlink" title="Share"></a>Share</h3><p>分享一篇有观点和思考的技术文章</p>

        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

    
  </div>

  



          </div>
          

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/shelly.jpg"
      alt="Shelly An">
  <p class="site-author-name" itemprop="name">Shelly An</p>
  <div class="site-description" itemprop="description">Python、Oracle，金融科技</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">2</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Shelly An</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">
      
    主题 – <a href="https://pisces.theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.4.1
  </div>

        












        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js?v=3.1.0"></script>
  <script src="/lib/pjax/pjax.min.js?v=0.2.8"></script>
  <script src="//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/utils.js?v=7.4.1"></script><script src="/js/motion.js?v=7.4.1"></script>
<script src="/js/schemes/pisces.js?v=7.4.1"></script>
<script src="/js/next-boot.js?v=7.4.1"></script>
  <script>
var pjax = new Pjax({
  selectors: [
    'head title',
    '#page-configurations',
    '.content-wrap',
    '.post-toc-wrap',
    '#pjax'
  ],
  switches: {
    '.post-toc-wrap': Pjax.switches.innerHTML
  },
  analytics: false,
  cacheBust: false,
  scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
  document.querySelectorAll('script[pjax], script#page-configurations, #pjax script').forEach(element => {
    var code = element.text || element.textContent || element.innerHTML || '';
    var parent = element.parentNode;
    parent.removeChild(element);
    var script = document.createElement('script');
    if (element.id) {
      script.id = element.id;
    }
    if (element.className) {
      script.className = element.className;
    }
    if (element.type) {
      script.type = element.type;
    }
    if (element.src) {
      script.src = element.src;
      // Force synchronous loading of peripheral JS.
      script.async = false;
    }
    if (element.getAttribute('pjax') !== null) {
      element.setAttribute('pjax', '');
    }
    if (code !== '') {
      script.appendChild(document.createTextNode(code));
    }
    parent.appendChild(script);
  });
  NexT.boot.refresh();
  // Define Motion Sequence & Bootstrap Motion.
  if (CONFIG.motion.enable) {
    NexT.motion.integrator
      .init()
      .add(NexT.motion.middleWares.postList)
      .bootstrap();
  }
  NexT.utils.updateSidebarPosition();
});
</script>




  




















    <div id="pjax">

  

  
    
      
    
      
    
  

  

  


    </div>
</body>
</html>
